<?php
// +---------------------------------------------------------------------+
// | OneBase    | [ WE CAN DO IT JUST THINK ]                            |
// +---------------------------------------------------------------------+
// | Licensed   | http://www.apache.org/licenses/LICENSE-2.0 )           |
// +---------------------------------------------------------------------+
// | Author     | Bigotry <3162875@qq.com>                               |
// +---------------------------------------------------------------------+
// | Repository | https://gitee.com/Bigotry/OneBase                      |
// +---------------------------------------------------------------------+

namespace app\admin\controller;

use app\common\model\OtcOrder;
use app\common\model\Transfer;
use app\common\model\UserAccount;
use app\common\model\UserAccountLog;
use think\Db;

/**
 * 应用商店控制器
 */
class Appstore extends AdminBase
{


    
    /**
     * 游戏币总转换记录列表
     */
    public function game_coin_list()
    {



        $this->assign('list', $this->logicAppstore->game_coin_list($this->param,'a.*,c.username','a.create_time desc',50));
        $this->assign('param',$this->param);
        return $this->fetch();
    }


    /**
     * 后台充值页面
     */
    public function recharge()
    {

        if(request()->isPost()){
            $this->jump($this->logicMember->recharge($this->param));

        }

        $this->assign('info', $this->logicMember->getMemberInfo($this->param,'*','create_time desc',50));
        $this->assign('true',true);
        return $this->fetch();
    }

    /**
     * 转出娱乐城导出
     */
    public function exportTransferList()
    {

        $this->logicAppstore->exportTransferList($this->param);
    }



 /**
  * 后台充值页面
  */
    public function add_withdrwal()
    {

        if(request()->isPost()){
            $this->jump($this->logicAppstore->otc_order_edit($this->param));

        }



        return $this->fetch('order_edit');
    }
    /**
     * 兑换游戏币审核
     */
    public function  setStatus(){
        $this->jump($this->logicAppstore->setStatus($this->param));

    }


    /**
     * 总包提现到钱包记录列表
     */
    public function wallet_withdrawal_list()
    {

        $this->param['paytype']=4;

        $this->assign('list', $this->logicAppstore->wallet_withdrawal_list($this->param,'a.*,c.username','a.create_time desc',50));
        $this->assign('wallet', \app\common\model\Wallet::all(['is_currency'=>1,'status'=>1,'is_virtual'=>1]));
        $this->assign('param',$this->param);
        return $this->fetch();
    }


    /**
     * 总包提现到微信支付宝记录列表
     */
    public function cash_withdrawal_list()
    {
        if(!empty($this->param['otcorder'])){
            $info= OtcOrder::get($this->param['id']);
            $this->assign('info',$info);
            $this->assign('param',$this->param);
            return $this->fetch('trade_order_detail');
        }
        if(!empty($this->param['payinfo'])){
          $paylist= $this->logicAppstore->pay_list($this->param);
           $this->assign('paylist',$paylist);
           return $this->fetch('pay_detail');
       } else{
           $this->assign('list', $this->logicAppstore->wallet_withdrawal_list($this->param,'a.*,c.username,c.mobile,c.is_king,c.is_shop,c.is_company','a.create_time desc',50));
           $this->assign('param',$this->param);
           return $this->fetch();
       }


    }

    /**
     * 总包提现到钱包导出
     */
    public function exportWalletWithdrawalList()
    {
        $this->param['paytype']=4;
        $this->logicAppstore->exportWalletWithdrawalList($this->param);
    }
    /**
     * 总包提现法币导出
     */
    public function exportCashWithdrawalList()
    {
        $this->logicAppstore->exportWalletWithdrawalList($this->param);
    }

    /**
     * 提现审核
     */
    public function  trade_check(){
        !empty($this->param['match']) && $this->jump($this->logicAppstore->match_order($this->param));
        if(!empty($this->param['is_match'])){
            $this->assign('param',$this->param);
            $this->assign('shop_list',\app\common\model\OtcShop::all(['status'=>1,'state'=>2]));
            return $this->fetch('match_order');
        }
        IS_POST && $this->jump($this->logicAppstore->trade_check($this->param));
        $this->assign('info',Transfer::get($this->param['id']));
        $this->assign('param',$this->param);
        return $this->fetch();

    }


}
